Managing Tags and Custom Fields
Tags and custom fields are powerful tools for organizing and adding metadata to your videos. This guide will walk you through the process of managing tags and custom fields for videos using the Teyuto API.
Managing Tags
Creating a Tag
To create a new tag:
- Use the
POST /tags
endpoint - Set up your request headers:
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Authorization: YOUR_API_KEY - In the request body, include:
title
: The name of the tagdescription
: A description of the tagprivacy
: The privacy setting (e.g., "hidden", "public", "registered")
Example cURL request:
curl -X POST "https://api.teyuto.tv/v2/tags" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=NewTag&description=This is a new tag&privacy=public"
Editing a Tag
To edit an existing tag:
- Use the
PATCH /tags/{id}
endpoint - Replace
{id}
with the tag ID - In the request body, include the fields you want to update:
title
: The new name of the taghidden
: Set to "true" to hide the tag, "false" to make it visible
Example cURL request:
curl -X PATCH "https://api.teyuto.tv/v2/tags/12345" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=UpdatedTag&hidden=false"
Deleting a Tag
To delete a tag:
- Use the
DELETE /tags/{id}
endpoint - Replace
{id}
with the tag ID
Example cURL request:
curl -X DELETE "https://api.teyuto.tv/v2/tags/12345" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"
Applying Tags to Videos
When creating or updating a video, you can apply tags using the tag_ids[]
parameter. This is an array of tag IDs that you want to associate with the video.
Example (when creating a new video):
curl -X POST "https://api.teyuto.tv/v2/videos/vod" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=My Video&description=A great video&tag_ids[]=123&tag_ids[]=456"
Managing Custom Fields
Custom fields allow you to add additional metadata to your videos.
Creating a Custom Field
To create a new custom field for videos:
- Use the
POST /customfields/videos
endpoint - In the request body, include:
key
: The unique identifier for the custom fieldlabel
: The display name for the custom fieldshow
: Set to "true" to make the field visibleorder
: The display order of the field
Example cURL request:
curl -X POST "https://api.teyuto.tv/v2/customfields/videos" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "key=director&label=Director&show=true&order=1"
Editing a Custom Field
To edit an existing custom field:
- Use the
PATCH /customfields/videos/{key}
endpoint - Replace
{key}
with the custom field's key - In the request body, include the fields you want to update
Example cURL request:
curl -X PATCH "https://api.teyuto.tv/v2/customfields/videos/director" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "label=Film Director&show=true&order=2"
Deleting a Custom Field
To delete a custom field:
- Use the
DELETE /customfields/videos/{key}
endpoint - Replace
{key}
with the custom field's key
Example cURL request:
curl -X DELETE "https://api.teyuto.tv/v2/customfields/videos/director" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"
Using Custom Fields with Videos
When creating or updating a video, you can include custom field data in the request. The API documentation doesn't specify exactly how to do this, but typically it would be included in the request body, possibly as a JSON object.
Best Practices
-
Consistent Tagging: Develop a consistent tagging strategy to make it easier to organize and search for videos.
-
Meaningful Custom Fields: Create custom fields that add valuable metadata to your videos, such as director, genre, or release date.
-
Regular Cleanup: Periodically review and clean up unused tags and custom fields to keep your system organized.
-
API Key Security: Always keep your API key secure and never expose it in client-side code.
-
Error Handling: Implement proper error handling in your code to manage API response errors gracefully.
By effectively using tags and custom fields, you can enhance the organization and searchability of your video content on the Teyuto platform.